package com.example.myorder.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.myorder.entity.Order;
import com.example.myorder.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author li
 * @since 2024-11-07
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @RequestMapping("/getOrderById")
    public Order getOrderById(Integer id){
        return orderService.getById(id);
    }

    @RequestMapping("/getOrderListByUserId")
    public List<Order> getOrderListByUserId(Integer userId){
        log.info("excute getOrderListByUserId,userId:{}",userId);
        return orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getUserId,userId));
    }

}
